package com.ys.web.user.complain.po;

import com.ys.utils.base.j2se.Common;
import com.ys.utils.base.j2se.StringHandler;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @author quxinjun
 * @version 1.0.0
 * @ClassName ComplainPO.java
 * @Description 投诉实体类
 * @createTime 2021年05月24日 11:14:00
 */
@Data
@Accessors(chain = true)
@Table(name = "s_complain")
public class ComplainPO {

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long id;

    /**
     * 投诉编码
     */
    public Integer code;

    /**
     * 投诉原因
     */
    public String cause;

    /**
     * 证据图片
     */
    public String pic;

    /**
     * 投诉内容
     */
    public String content;

    /**
     * 电话
     */
    public String phone;

    /**
     * 是否处理
     */
    public Boolean isDeal;

    /**
     * 创建时间
     */
    public String createTime;

    /**
     * 修改时间
     */
    public String updateTime;

    /**
     * 发起人
     */
    public Long userId;

    /**
     * 组id
     */
    public String objId;

    /**
     * 状态
     */
    public Integer status;

    /**
     * 投诉类型
     */
    public Integer type;

    /**
     * @param complainPO
     * @title validate
     * @description 验证参数
     * @author quxinjun
     * @updateTime 2021/5/24 11:53
     * @return: java.lang.String
     */
    public String validate(ComplainPO complainPO) {
        if(StringHandler.isEmpty(complainPO.getType()) || (complainPO.getType() != 1 && complainPO.getType() != 2)){
            return "参数传递错误";
        }
        if (StringHandler.isEmpty(complainPO)) {
            return "参数传递错误";
        }
        if (StringHandler.isEmpty(complainPO.getCode()) || complainPO.getCode() == 0) {
            return "投诉原因编码必填";
        }

        if (StringHandler.isEmpty(complainPO.getCause())) {
            return "投诉原因必填";
        }

        if (StringHandler.isEmpty(complainPO.getPhone())) {
            return "电话号码必填";
        }else{
            boolean flag = Common.isTelPhone(complainPO.getPhone());
            if(!flag){
                return "电话号码格式错误";
            }
        }

        if (StringHandler.isEmpty(complainPO.getObjId()) || "0".equals(complainPO.objId)) {
            return "投诉对象不能为空";
        }

        if (StringHandler.isEmpty(complainPO.getContent())) {
            return "投诉内容必填";
        }
        return null;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getCause() {
        return cause;
    }

    public void setCause(String cause) {
        this.cause = cause;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Boolean getIsDeal() {
        return isDeal;
    }

    public void setIsDeal(Boolean deal) {
        isDeal = deal;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getObjId() {
        return objId;
    }

    public void setObjId(String objId) {
        this.objId = objId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }
}
